<?php
namespace App\Traits;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/2
 * Time: 13:05
 */
trait FormatResponseTrait
{
    /**
     * @param $message
     * @param int $status
     * @return \Illuminate\Http\JsonResponse
     * 响应一个错误
     */
    public function error($message, $status = 400)
    {
        return response()->json([
            'msg' => $message,
        ], $status);
    }

    /**
     * @param int $status
     * @param array $data
     * @return \Illuminate\Http\JsonResponse
     * 响应一个成功信息
     */
    public function success($data = [], $status = 200)
    {
        return response()->json($data, $status);
    }






}